package cn.jbit.bio;


import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

/**
 * 源码学院只为培养优秀的bat程序员而生
 *
 * @author 学员张在成
 * @data 2020/8/2
 */
public class Client {

    public static void main(String[] args) throws IOException {

        //创建Socket
        Socket socket=null;
        socket=new Socket("localhost",8080);

        OutputStream outputStream=null;
        InputStream inputStream=null;

        String messsage="张杰";
        byte[] bytes=messsage.getBytes();
        outputStream=socket.getOutputStream();

        outputStream.write(bytes);

        /*int length=0;

        byte[] bytes=new byte[1024];

        while ((length=inputStream.read(bytes))>0){
            inputStream=socket.getInputStream();
            System.out.println("client input is"+new String(bytes));

        }*/

        outputStream.flush();

        socket.close();
    }

}
